package main

import (
	"fmt"
	 "github.com/github-user/JsonMarshal"
	 "encoding/json"
)

type Example struct {
	ID    int                    `json:"id"`
	bID   int                    `json:"-"`
	MALE   bool                   `json:"Men,omitempty"`
	FEMALE bool                   `json:"Women,omitempty"`
	NAME string                 `json:",omitempty"`
	DETAIL map[string]interface{} `json:"test,omitempty"`
}

type TestMytag struct {
	ID    int                    `mytag:"id"`
	bID   int                    `mytag:"-"`
	MALE   bool                   `mytag:"Men,omitempty"`
	FEMALE bool                   `mytag:"Women,omitempty"`
	NAME string                 `mytag:",omitempty"`
	DETAIL map[string]interface{} `mytag:"test,omitempty"`
}


func main() {
	fmt.Println("Test Mytag:")
	group_a := TestMytag{
		ID:    1834,
		bID:   2128,
		MALE:   false,
		FEMALE: true,
		NAME: "zxy",
		DETAIL: map[string]interface{}{"Address": "SYSU", "Phone": "123456", "Salary": 0},
	}
	js, err := jsonm.JSONMarshal(group_a)
	if err == nil {
		fmt.Println(string(js))
	}else {fmt.Errorf("error struct json: %s", err)}
	
	fmt.Println("Test Correctness:")
	group_b := Example{
		ID:    1834,
		bID:   2128,
		MALE:   false,
		FEMALE: true,
		NAME: "zxy",
		DETAIL: map[string]interface{}{"Address": "SYSU", "Phone": "123456", "Salary": 0},
	}
	jsa, erra := jsonm.JSONMarshal(group_b)
	jsb, errb := json.Marshal(group_b)
	if erra == nil && errb == nil{
		fmt.Println(string(jsa))
		fmt.Println("vs.")
		fmt.Println(string(jsb))
	}else {
		fmt.Println("Error!")
	}
}